package com.wanxi.study;

public class OneArray {
    public static void main(String[] args) {

        //静态初始化
        double[] prices;
        prices = new double[]{20.22, 22.11, 25.22, 44.20, 44.28};

        //动态初始化
        String[] food = new String[5];

        int[] number = new int[5];


        int[] number1 = new int[]{1, 2, 3, 4, 5};


        //调用数组的元素
        System.out.println(prices[4]);
        System.out.println(number1[0]);

        food[0] = "小菜";
        food[1] = "中菜";
        food[2] = "大菜";
        food[3] = "早菜";
        food[4] = "晚菜";

        //数组的长度.length

        System.out.println(prices.length);

        //遍历数组的元素

        for (int i = 0; i < prices.length; i++) {
            System.out.println(prices[i]);
        }

        for (int i = 0; i < number1.length; i++) {

            int a = number1[i];

            System.out.println(a);
        }
        //静态初始化的整型数组的元素默认为0
        //静态初始化的浮点数组的元素默认为0.0
        //静态初始化的字符数组的元素默认为0（或者理解为“\u0000”）
        //静态初始化的布尔数组的元素默认为false
        //静态初始化的引用数据数组的元素默认为null

    }


}
